package GUI;

import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import java.awt.SystemColor;

public class MainMenu extends JFrame {

	private JFrame frame;
	private Sale sale;
	private ProductMangement proMan;
	private PersonManagement perMan;
	private String userName;
	private String passWord;
	
	/**
	 * Launch the application.
	 */


	/**
	 * Create the application.
	 */
	public MainMenu(String username, String password) {
		this.userName = username;
		this.passWord = password;
		makeFrame();
		makeTextPane();
		makeLabels();
		makeButtons();
		frame.setVisible(true);
		
	}

	/**
	 * Initialize the contents of the frame.
	 */

	private void makeFrame()
	{
		frame = new JFrame();
		frame.setResizable(false);
		frame.setBounds(100, 100, 416, 334);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(null);
	}
	
	//Creates buttons
	private void makeButtons()
	{
		JButton buttonCusAndEmp = new JButton("Cus. & Emp. Management");
		buttonCusAndEmp.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				goToPersonMangement();
			}
		});
		buttonCusAndEmp.setBounds(228, 195, 160, 41);
		frame.getContentPane().add(buttonCusAndEmp);
		
		JButton buttonProductManagement = new JButton("Product Management");
		buttonProductManagement.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				goToProductMangement();
			}
		});
		buttonProductManagement.setBounds(21, 195, 160, 41);
		frame.getContentPane().add(buttonProductManagement);
		
		JButton btnSale = new JButton("Sale");
		btnSale.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				goToSale();
			}
		});
		btnSale.setBounds(21, 132, 160, 41);
		frame.getContentPane().add(btnSale);
		
		JButton buttonStock = new JButton("Statistics");
		buttonStock.setBounds(228, 132, 160, 41);
		frame.getContentPane().add(buttonStock);
		
		JLabel lblNewLabel = new JLabel("Au2Parts");
		lblNewLabel.setFont(new Font("Arial", Font.BOLD, 67));
		lblNewLabel.setBounds(62, 45, 335, 60);
		frame.getContentPane().add(lblNewLabel);
	}
	
	//Creates the textpane
	private void makeTextPane()
	{
		JTextPane infoTextPane = new JTextPane();
		infoTextPane.setFont(new Font("Tahoma", Font.PLAIN, 13));
		infoTextPane.setBackground(SystemColor.control);
		infoTextPane.setText(userName);
		infoTextPane.setBounds(139, 247, 136, 24);
		frame.getContentPane().add(infoTextPane);
	}
	
	//Method launches the sale UI
	private void goToSale()
	{
		sale = new Sale();
		
	}
	
	//Method launches the ProM UI
	private void goToProductMangement()
	{
		proMan = new ProductMangement();
	}
	
	//Method launches the PerM UI
	private void goToPersonMangement()
	{
		perMan = new PersonManagement();
	}
	
	//Creates Lables
	private void makeLabels()
	{
		JLabel lblUserInformations = new JLabel("You're logged in as:");
		lblUserInformations.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lblUserInformations.setBounds(21, 246, 123, 24);
		frame.getContentPane().add(lblUserInformations);
	}
}
